package com.docker.sys.role.roleMenu;

import com.docker.core.constant.MainConstant;
import com.docker.core.mvc.dao.BaseDao;
import com.jfinal.plugin.activerecord.Record;

import java.util.List;

/**
 * @Author ldl
 * @Create 2020/09/23 023 11:28
 */
public class RoleMenuDao extends BaseDao {

    @Override
    protected String getDbName() {
        return MainConstant.DB_DOCKER;
    }

    @Override
    protected String getSqlTplNameSpace() {
        return "sys.role.menu";
    }

    public List<Record> tree(String roleId, String appId) {
        return tplList("tree", roleId, appId);
    }

    public List<Record> now(String roleId, String appId) {
        return tplList("now", roleId, appId);
    }

    public boolean save(Record roleMenu) {
        return save("sys_role_menu", "rm_id", roleMenu);
    }

    public void delete(String roleId, String menuId) {
        tplDelete("delete", roleId, menuId);
    }

    public void deleteByRoleId(String roleId) {
        tplDelete("delete.by.roleId", roleId);
    }
}
